﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Restbucks.Shared.Domain;
using System.IO;
using Restbucks.Shared.Mappers;
using Restbucks.Shared.Representations;
using System.Xml.Serialization;
using System.Xml.Linq;

namespace Restbucks.Client
{
    class RestbucksClient
    {
        static OrderRepresentationMapper _oMapper = new OrderRepresentationMapper();

        public static void CallRestbucksServer()
        {
        }

        internal static void debugCreateOrder()
        {
            // snippet: how to turn a xml file of an OrderRep into an Order domain object via the mapper 
            //StreamReader sr = new StreamReader("sample/order1.xml");
            //XmlSerializer xmlSerializerOrder = new XmlSerializer(typeof(OrderRepresentation));
            //OrderRepresentation orderRep = (OrderRepresentation) xmlSerializerOrder.Deserialize(sr);
            //Order neworder = _oMapper.GetDomainObject(orderRep);

            XDocument orderReq = XDocument.Load("sample/order1.xml");
            
            XDocument orderRes = Server.ServerFacade.Order(Restbucks.Server.ServerFacade.Operation.PUT, orderReq);

        }

        internal static OrderRepresentation[] GetOrders()
        {
            // expect to get an array of OrderRep's
            XDocument orderRes = Server.ServerFacade.Order(Restbucks.Server.ServerFacade.Operation.GET, "");

            Debug.Log(orderRes.ToString());
            return null;
        }
    }
}
